import { orderStatusMap } from '@/service/type/order';
import { Badge } from '../ui/badge';

const colors: Record<string, string> = {
  unpaid: 'bg-zinc-500 hover:bg-zinc-400',
  unaccepted: 'bg-orange-500 hover:bg-orange-400',
  pending: 'bg-yellow-500 hover:bg-yellow-400',
  delivering: 'bg-blue-500 hover:bg-blue-400',
  completed: 'bg-green-500 hover:bg-green-400',
  canceled: 'bg-red-500 hover:bg-red-400',
};

const statusMap = Object.entries(orderStatusMap).reduce(
  (acc, [key, value]) => {
    acc[key] = {
      text: value,
      color: colors[key],
    };
    return acc;
  },
  {} as Record<string, { text: string; color: string }>,
);

export default function OrderStatusBadge({
  status,
}: { status: keyof typeof orderStatusMap }) {
  return (
    <Badge className={statusMap[status].color}>{statusMap[status].text}</Badge>
  );
}
